<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>소셜커머스 모음 :: Social Curator</title>
	<link href="{{ static_path.css }}/main.css" rel="stylesheet" type="text/css"></link>
	<script type="text/javascript" src="{{ static_path.js }}/jquery-1.7.min.js"></script>
</head>
<body>
	<div align="center">
	  <div align="left"  style="width:954px;">	   
			<!-- Header start-->
			<div id="header">
				<!-- Logo -->
				<div align="center" style="margin:20px 0px 10px 0px;color:#C04023;font-size:30px;font-weight:bold;font-family:Arial, sans-serif;">Social Curator</div>					
				<!-- Top menu -->
				<div id="topmenu">
					<ul id="topmenu_navi">
						<li><a class="{% if menu_name=="today_coupon"%}menu_on{% endif %}" href="/today_coupon">오늘의 쿠폰</a></li>
						<li><a class="{% if menu_name=="today_tiled"%}menu_on{% endif %}" href="/today_tiled">오늘의 쿠폰(타일)</a></li>
					</ul>
					<div id="topmenu_search">
						<div style="float:left">
							<img src="{{ static_path.images }}/topmenu_magnify.png">
						</div>
						<input type="text" id="topmenu_search_box" name="keyword" value="{{keyword}}">
					</div>
				</div>
			</div>
			<!-- Header end -->		
				
			<!-- Content start -->
			<div id="content">
			  {% block content %}
			  {% endblock %}  
			</div>			
			<!-- Content end -->
					
			<!-- Bottom start -->		
			<div class="bottom">
				<img src="{{ static_path.images }}/bottom_line.png"><br>
				<div align="center">
				 	<b>Copyright © SocialCurator 2012.</b><br>
					※ SocialCurator는 상품에 직접 관여하지 않으며 상품 주문, 배송 및 환불의 의무와 책임은 각 판매업체에 있습니다.	
				</div>
			</div>
			<!-- Bottom end -->		
		</div>
	</div>
	<script type="text/javascript">
	var g_keyword = "{{keyword}}";
	var g_start_id = 0;
	var g_limit = 15;
	var b_is_loading = false;
	var b_has_more_data = true;
	
	$("#topmenu_search_box").keyup(function(event)
	{
      if(event.keyCode == 13)
      {
        search($("#topmenu_search_box").val());
      }
    });
    
    String.prototype.trim = function() 
    {
		return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	}
	
	function init()
	{
		b_is_loading = false;
		b_has_more_data = true;
		g_start_id = 0;
		$('div#deal_list').empty();
	}
	
	function search(keyword)
	{
		g_keyword = keyword;	
		init();	
    	lastPostFunc();
	}
	
	function lastPostFunc() 
	{	
		if(b_has_more_data == false || b_is_loading == true)
		{
			return;
		}
		
		b_is_loading = true;
	    $('div#lastPostsLoader').html('<div align=\'center\'><img src="{{ static_path.images }}/ajax-loader.gif"></div>');	    
	    $.get("/searcher?action=extend&output=html&keyword=" + encodeURIComponent(g_keyword) + "&start=" + g_start_id,
    	function(data)
    	{
    		if(data.trim().length == "")
    		{
    			b_has_more_data = false;
    		}    		
			else if($('div#deal_list').is(':empty'))
    		{    
    			g_start_id += g_limit;	
    			$('div#deal_list').html(data);	
    		}
    		else if (data != "") 
    	    {   
    	    	g_start_id += g_limit; 
	        	$(".deal_item:last").after(data);            
	        } 
        	$('div#lastPostsLoader').empty();
        	b_is_loading = false; 
    	}); 
	}; 
	</script>	
</body>